//==========================================================================
// Copyright (c) 2000-2008,  Elastos, Inc.  All Rights Reserved.
//==========================================================================
#if _MSC_VER > 1000
#pragma once
#endif

#if !defined(__CKTFSDIRECTORY_H__)
#define __CKTFSDIRECTORY_H__

#define _NO_CKTFSDIRECTORY_CLASSOBJECT_
#include "_CKtfsDirectory.h"
#include <fatfile.h>

class CKtfsDirectory : public _CKtfsDirectory
{
public:
    CARAPI Sync();

    CARAPI GetType(
        /* [out] */ FileType * pType);

    CARAPI GetAccessTime(
        /* [out] */ Int32 * pTime);

    CARAPI SetAccessTime(
        /* [in] */ Int32 time);

    CARAPI GetModificationTime(
        /* [out] */ Int32 * pTime);

    CARAPI SetModificationTime(
        /* [in] */ Int32 time);

    CARAPI GetCreateTime(
        /* [out] */ Int32 * pTime);

    CARAPI CheckAccessMode(
        /* [in] */ FileAccessMode mode);

    CARAPI GetAccessMode(
        /* [out] */ FileAccessMode * pMode);

    CARAPI SetAccessMode(
        /* [in] */ FileAccessMode mode);

    CARAPI GetShareMode(
        /* [out] */ FileShareMode *pMode);

    CARAPI SetShareMode(
        /* [in] */ FileShareMode mode);

    CARAPI Lookup(
        /* [in] */ WString wstrPath,
        /* [out] */ IBasicFile * * piBasicFile);

    CARAPI CreateFile(
        /* [in] */ WString wstrPath,
        /* [in] */ FileAccessMode cmode,
        /* [in] */ Boolean bExclusive,
        /* [out] */ IBasicFile * * piBasicFile);

    CARAPI DeleteFile(
        /* [in] */ WString wstrPath);

    CARAPI Rename(
        /* [in] */ WString wstrSrcPath,
        /* [in] */ IBasicDirectory * pNewDir,
        /* [in] */ WString wstrDestPath);

    CARAPI CreateDirectory(
        /* [in] */ WString wstrPath,
        /* [in] */ FileAccessMode mode);

    CARAPI DeleteDirectory(
        /* [in] */ WString wstrPath);

    CARAPI GetDirEntries(
        /* [out] */ IWStringEnumerator * * piEntryNameEnumerator);

    CARAPI AddFileMonitor(
        /* [out] */ IEvent **ppEvent);

    CARAPI RemoveFileMonitor(
        /* [in] */ IEvent *pEvent);

    ~CKtfsDirectory();

    CKtfsDirectory(class CFatFile *pCFatFile) : m_pCFatFile(pCFatFile)
    {
        m_pCFatFile->AddRef();
    }

private:
    CKtfsDirectory() { }

    ECode ParseRelativePath(const wchar_t *pRelativePath,
                            CKtfsDirectory **ppRetDirectory,
                            wchar_t **ppLastName);

private:
    // TODO: Add your private member variables here
    class CFatFile *m_pCFatFile;

    Boolean IsValidFatFile(class CFatFile *pCFatFile);
    inline void Lock();
    inline void Unlock();
};

#endif //!(__CBASICDIRECTORY_H__)
